

angular.module('starter.controllers', [])

.controller('AppCtrl', function($scope, $ionicModal, $state,$timeout) {

  $scope.loginData = {};

  $ionicModal.fromTemplateUrl('templates/login.html', {
    scope: $scope
  }).then(function(modal) {
    $scope.modal = modal;
  });

  $scope.closeLogin = function() {
    $scope.modal.hide();
  };

  window.netinfo = function (event) {
    $scope.netinfo = event;
    $scope.$apply();
 }
  //进入测试页面
  $scope.jumpTest = function() {

    $state.go('testPage');

  };  

  $scope.jumpMap = function() {

    $state.go('mapPage');

  };

  // Open the login modal
  $scope.login = function() {
    $scope.modal.show();
  };

  $scope.doLogin = function() {
    console.log('Doing login', $scope.loginData);

    $timeout(function() {
      $scope.closeLogin();
    }, 1000);


  };
})
.controller('PlaylistsCtrl', function($scope) {

  window.netinfo = function (event) {
    $scope.netinfo = event;
    $scope.$apply();
 }
  $scope.playlists = [
    { title: '微信', id: 1 },
    { title: '支付宝', id: 2 },
    { title: '翼支付', id: 3 },
    { title: '银联支付', id: 4 },
    { title: '网商卡', id: 5 },
    { title: '充值卡', id: 6 }
  ];

})

.controller('PlaylistCtrl', function($scope, $stateParams) {
  window.netinfo = function (event) {
    $scope.netinfo = event;
    $scope.$apply();
 }

});
